package subject_set.offer100;

/**
 * @author haomin
 * @date 2022/10/27 16:13
 **/
public class Offer64 {
    class Solution {
        public int sumNums(int n) {
            if(n == 1) return 1;
            return n + sumNums(n-1);
        }
    }

    // 2. &&
    class Solution1 {
        public int sumNums(int n) {
            boolean flag = n > 0 && (n += sumNums(n-1)) > 0;
            return n;
        }
    }

    // 3. ||
    class Solution3 {
        public int sumNums(int n) {
            boolean flag = n == 1 || (n += sumNums(n-1)) > 0;
            return n;
        }
    }
}